package tcpserver.handler.in;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class FrameLimiter extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {

        int overflow = Integer.class.cast(msg);

        if(overflow >= 128) ctx.channel().config().setAutoRead(false);

        if(overflow <= 0) ctx.channel().config().setAutoRead(true);
    }
}
